<template>
  <router-view v-slot="{ Component }">
    <div
      v-if="!notShowBackBtnRouterNames.includes(router.currentRoute.value.name)"
      style="display:flex;justify-content:  space-between "
    >
      <el-text
        style="font-size: large;"
        type="primary"
        @click="backClick"
      >
        <el-icon>
          <Back />
        </el-icon>
        返回
      </el-text>
      <el-text
        style="font-size: large;"
        type="primary"
        v-if="adminList.includes(WORKID)"
        @click="monthClick"
      >
        月度报表
        <el-icon>
          <Right />
        </el-icon>
      </el-text>
      <el-text
        style="font-size: large;"
        type="primary"
        v-if="['13566511216'].includes(WORKID)"
        @click="printClick"
      >
        打印
        <el-icon>
          <Right />
        </el-icon>
      </el-text>
    </div>
    <transition>
      <div>
        <!-- <keep-alive> -->
        <component :is="Component" />
        <!-- </keep-alive> -->
      </div>
    </transition>
  </router-view>
</template>

<script>
import { Back, Right } from '@element-plus/icons-vue';
import { useRouter } from 'vue-router';
import myAxios from './myAxios/myAxios';
import axios from 'axios';
import myAxiosWXPost from './myAxios/myAxiosWXPost';
import VueCookie from 'vue-cookie';
export default {
  name: 'app',
  components: {
    Back,
    Right,
  },
  setup () {
    let adminList = ['14602', '8030', '0120'];
    let WORKID = VueCookie.get('userid');
    let router = useRouter();
    let notShowBackBtnRouterNames = ['manager', 'home', 'weekCd', 'cdManager', 'weekRoomManager', 'roomPrint'];
    // var data = JSON.stringify({
    //   'openId': 'ok-KS077NtZ3J0USjJSrMgM5tS44',
    //   'title': '123',
    //   'description': '345',
    //   'url': 'www.baidu.com',
    //   'picurl': '',
    //   'tokenname': 'ACCESS_TOKEN_WX_QDFW'
    // });
    // var config = {
    //   method: 'post',
    //   url: 'http://192.168.100.28:85/WorkWxMsgService/WxWorkMsgService.asmx?op=SendNews_wx',
    //   headers: {
    //     // 'Sec-Fetch-User': '?1',
    //     // 'Upgrade-Insecure-Requests': '1',
    //     // 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
    //     'Content-Type': 'application/x-www-form-urlencoded',
    //     'Accept': '*/*',
    //     // 'Host': '192.168.100.28:85',
    //     // 'Connection': 'keep-alive'
    //   },
    //   data: data
    // };

    // axios(config)
    //   .then(function (response) {
    //     console.log(JSON.stringify(response.data));
    //   })
    //   .catch(function (error) {
    //     console.log(error);
    //   });

    let backClick = async function () {
      router.push('/');
      // router.back();
    };
    let monthClick = async function () {
      router.push('/manager/weekRoomManager');
      // router.back();
    };
    let printClick = async function () {
      router.push('/roomPrint');
    };
    return {
      adminList,
      WORKID,
      backClick, monthClick, printClick,
      router, notShowBackBtnRouterNames,
    };
  },
}
</script>

<style>
.el-message-box__message p {
  word-break: break-all;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>
